<?php

namespace App\Observers;

use App\Exceptions\ApiException;
use App\Models\Banner;
use App\Models\Image as ImageModel;

class BannerObserver
{
    public function saving(Banner $banner)
    {
        $img=ImageModel::where('id',$banner['img_id'])->first();
        if(!$img)
            throw new ApiException("图片不存在");
        return $banner;
    }
}
